<?php
if (!defined('__COLA_DIR__')) exit;
/**
 * 密码输入表单项帮手
 *
 * @author edikud
 * @package Form
 * @copyright Copyright (c) 2019 Cola (http://www.mcooo.com)
 * @license GNU General Public License 2.0
 */

class Form_Password extends Form_Group
{
    /**
     * 初始化当前输入项
     *
     * @access public
     * @param string $name 表单元素名称
     * @param array $options 选择项
     * @return Element
     */
    public function input($name = NULL, array $options = NULL)
    {
        $input = (new Element('input'))->setAttr(array(
		    'id' => 'input-' . self::$uniqueId, 
			'name' => $name, 
			'type' => 'password', 
			'class' => 'form-control'));
        $this->label->setAttr('for', 'input-' . self::$uniqueId);
        $this->set($input);
        return $input;
    }

    /**
     * 设置表单项默认值
     *
     * @access protected
     * @param string $value 表单项默认值
     * @return void
     */
    protected function _value($value)
    {
        $this->input->setAttr('value', htmlspecialchars($value));
    }
}
